package day_2022_4_to_7.leetcode;

/**
 * @author haomin
 * @date 2022/06/06 22:26
 **/
public class Num8 {
    public static void main(String[] args) {
        myAtoi("-100");
    }

    public static int myAtoi(String s) {
        boolean flag = false;
        int num = 0;
        for (int i = 0; i < s.length(); i++) {
            char cur = s.charAt(i);
            while (cur == ' '){
                i++;
            }
            if(cur == '-'){
                flag = true;
                i++;
            }
            if(Character.isDigit(cur)){
                while (Character.isDigit(cur)){
                    num = Integer.valueOf(cur) + num*10;
                    i++;
                }
                if(flag == true){
                    System.out.println(-num);
                }else {
                    System.out.println(num);
                }
            }
        }
        return 0;
    }
}